package com.weipu.common.facade.model;

import java.util.ArrayList;
import java.util.List;

import org.json.JSONArray;
import org.json.JSONObject;

import com.weipu.common.constants.ServerConstant;

public class CreditCardInfo {
	private List<SimpleCreditCard> sCreditCards;

	private int totalRecords;
	
	//EGP或Geobill
	private String gatewayType;

	public List<SimpleCreditCard> getsCreditCards() {
		return sCreditCards;
	}

	public void setsCreditCards(List<SimpleCreditCard> sCreditCards) {
		this.sCreditCards = sCreditCards;
	}

	public int getTotalRecords() {
		return totalRecords;
	}

	public void setTotalRecords(int totalRecords) {
		this.totalRecords = totalRecords;
	}
    
	public String getGatewayType() {
		return gatewayType;
	}

	public void setGatewayType(String gatewayType) {
		this.gatewayType = gatewayType;
	}

	/**
	 * 解析CreditCardInfo对象
	 * @param data JSON对象
	 * @return
	 */
	public static CreditCardInfo jsonCreditCardInfoModel(JSONObject data) {
		CreditCardInfo creditCardInfo = null;
		if (data != null) {
			creditCardInfo = new CreditCardInfo();
			JSONArray simpleCreditCards=data.optJSONArray(ServerConstant.CreditCard.CREDITCARD_SIMPLECREDITCARD);
			if(null!=simpleCreditCards){
				List<SimpleCreditCard> creditCards=new ArrayList<SimpleCreditCard>();
				for(int i=0;i<simpleCreditCards.length();i++){
					SimpleCreditCard sCreditCard=SimpleCreditCard.jsonObjectSimpleCreditCard(simpleCreditCards.optJSONObject(i));
					creditCards.add(sCreditCard);
				}
				creditCardInfo.setsCreditCards(creditCards);
			}
			creditCardInfo.setTotalRecords(data.optInt(ServerConstant.CreditCard.CREDITCARD_TOTALRECORDS));
			creditCardInfo.setGatewayType(data.optString(ServerConstant.CreditCard.CREDITCARD_GATEWAY_TYPE));
		}
		
		return creditCardInfo;
	}
}
